_each = function(arr, fn, scope){
	if(!arr.pop && !arr.shift)arr = [arr];
	for(var i = 0, j = arr.length; i < j; i++){
		var _return = fn.call(scope || {} , arr[i], i, j, arr);
		if(_return === false){
			break;
		}
		if(_return == 'continue'){
			continue;
		}
	}
	return scope || arr;
}
/**
 * @class FileParser
 * @param {} disposition
 * @param {} stringData
 * @return {String}
 */
FileParser = function (disposition, stringData){
	var 
		// Parse的结果:Array
		 match
		// 档案的实体，开始index和实体的大小。
		,startIndex, bodySize;
		
	if(this.split.test(disposition) && (match = disposition.match(this.split))){
		if (!match[2]) {
			return 'continue'; // @dep 有何作用？？？
		}			

		// 只要算出，与body临界的index即可
		startIndex = stringData.indexOf(match[0]) + match[0].length;
		// body ＝ 总数 － 已匹配的head
		bodySize   = disposition.length - match.lastIndex;
		// 文件信息结构
		this.file = {
			 start       : startIndex
			,formField	 : match[1]
			,fileName 	 : match[2]
			,contentType : match[3]
			,size        : bodySize
		};
		this.file['path'] = this.getFilePath(this.file);
	}
}
FileParser.prototype = {
	split : /Content\-Disposition:\s+?form-data;\s+?name="(.*)";\s+?filename="(.*)"\r\nContent\-Type:\s+?(.*)\r\n\r\n/i
	/**
	 * 生成文件名。
	 * @private
	 * @param {Object}
	 * @return {String}
	 */
	,getFilePath:function (file){
		var extType;
			
		switch (file.contentType) {
			case "application/msword" :
				extType = ".doc";			
			case "application/pdf" :
				extType = ".pdf";			
			case "application/vnd.ms-excel" :
				extType = ".xls";			
			case "application/vnd.ms-powerpoint" :
				extType = ".ppt";			
			case "application/x-javascript" :
				extType = ".js";			
			case "application/x-shockwave-flash" :
				extType = ".swf";			
			case "application/xhtml+xml" :
				extType = ".xhtml";			
			case "application/zip" :
				extType = ".zip";			
			case "application/msaccess" :
				extType = ".mdb";			
			case "audio/midi" :
				extType = ".mid";			
			case "audio/mpeg" :
				extType = ".mp3";			
			case "audio/x-aiff" :
				extType = ".aif";			
			case "audio/x-mpegurl" :
				extType = ".m3u";			
			case "application/vnd.rn-realmedia" :
			case "audio/x-pn-realaudio" :
				extType = ".rm";			
			case "audio/x-pn-realaudio-plugin" :
				extType = ".rpm";			
			case "audio/x-realaudio" :
				extType = ".ra";			
			case "audio/wav" :
				extType = ".wav";			
			case "image/bmp" :
				extType = ".bmp";			
			case "image/gif" :
				extType = ".gif";		
			case "image/jpg" :
			case "image/jpeg" :
			case "image/pjpeg" :
				extType = ".jpg";
			case "image/x-png":
			case "image/png" :
				extType = ".png";			
			case "image/tiff" :
				extType = ".tiff";			
			case "image/vnd.wap.wbmp" :
				extType = ".wbmp";		
			case "text/css" :
				extType = ".css";			
			case "text/html" :
				extType = ".html";			
			case "text/plain" :
				extType = ".txt";			
			case "text/richtext" :
				extType = ".rtx";			
			case "text/rtf" :
				extType = ".rtf";			
			case "text/xml" :
				extType = ".xml";			
			case "video/mpeg" :
				extType = ".mpeg";			
			case "audio/x-ms-wma" :
				extType = ".wma";			
			case "video/quicktime" :
				extType = ".mov";			
			case "video/vnd.mpegurl" :
				extType = ".mxu";			
			case "video/x-msvideo" :
				extType = ".avi";			
			case "video/x-sgi-movie" :
				extType = ".movie";			
			case "application/octet-stream" :
			default :
				extType = "." + file.fileName.split(".").pop();
		}
		return Server.Mappath(Request.QueryString('uploadTo')() || '/upload') + '/' +  new Date().valueOf() + extType;
	}
};